<?php

class classe extends IgnitedRecord
{
	var $has_many = 'students';
	var $has_one = 'masters';
	
	function classe()
	{
        parent::IgnitedRecord();
    }
    
    function get()
    {
    	$query = $this->db->query(	"SELECT * FROM classes ");
    	$heading = array('ID', 'Nazwa klasy');
        $count = $this->db->count_all('classes');
    	
    	return array('query'=> $query, 'heading' => $heading, 'count' => $count);    	
    }
    
    function get_no_master()
    {
        $query = $this->db->query(	"SELECT c.id, c.name FROM classes c " .
                                    "WHERE c.id NOT IN (SELECT classe_id FROM masters) ");
    	$heading = array('ID', 'Nazwa klasy');


        $tmp = $this->db->query(	"SELECT c.id, c.name FROM classes c " .
                                    "WHERE c.id NOT IN (SELECT classe_id FROM masters) ");
        $count = $tmp->num_rows();
    	
    	return array('query'=> $query, 'heading' => $heading, 'count' => $count);    	
    }
    
    function update($_POST, $id)
    {
        $this->db->where('id', $id);
        $val['name'] = $_POST['name'];
        $this->db->update('classes', $val);
    }
    
    function get_related($id)
    {
        return array();
    }
}
?>
